package com.wfc.servlet.dish;

import com.wfc.entity.Dish;
import com.wfc.service.DishService;
import com.wfc.service.serviceImpl.DishServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/classification")
public class classification extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String category = req.getParameter("category");




        HttpSession session = req.getSession();

        //获取菜单信息
        DishService dishService1 = new DishServiceImpl();
        Dish dish = new Dish();


        //获取菜单信息
        DishService dishService = new DishServiceImpl();
        List<Dish> dishByCategory = dishService.selectBycategory(category);

        //session存所有菜品集合
        session.setAttribute("dishByCategory",dishByCategory);


        if (dishByCategory!=null) {
            req.getRequestDispatcher("system/classification.jsp").forward(req,resp);
        } else {
            System.out.println("这是get请求");
        }
    }
}
